1. Technical Field
The present invention relates to an image encoding apparatus that encodes an image, an image decoding apparatus that decodes encoded image data, and methods thereof, and relates particularly to a control method for parameter information referred to when decoding encoded image data obtained by arithmetically encoding a moving picture according to H.264/AVC.
2. Background Art
The standardization of “H.264/AVC” as a new video compression standard has been advanced by the formation of the JVT (Joint Video Team) by the ITU-T and the ISO/IEC JTC1, and was recognized as a recommendation in May of 2003. H.264/AVC is said to achieve approximately twice the compression rate of MPEG-2, which is used in satellite digital broadcasting, terrestrial digital broadcasting, and so on in Japan.
In order to achieve this high compression rate, H.264/AVC employs many video compression techniques, and carries out encoding by adaptively combining various compression techniques.
Entropy encoding (variable-length encoding) is included as one of the compression techniques employed by H.264/AVC. Two encoding schemes, or “CAVLC” and “CABAC”, are included in the entropy encoding method. One of these schemes is selected during decoding based on a predetermined flag that has been encoded along with the encoded image data that is to be decoded (called “encoded image data” hereinafter).
Here, “CAVLC” is an acronym for “Context-Adaptive Variable Length Coding”; when encoding the DCT coefficient, this CAVLC scheme encodes the run and level, which is the length of continuous zeroes, from the direction opposite to the scanning direction using a variable-length encoding table.
“CABAC”, meanwhile, is an acronym for “Context-based Adaptive Binary Arithmetic Coding”, and is a scheme that performs encoding by changing the appearance frequency of encoding targets that change over time.
When decoding encoded image data, CAVLC or CABAC is selected based on an “entropy_coding_mode_flag” encoded within a “pic_parameter_set_rbsp( )” in the header information. When this “entropy_coding_mode_flag” is “0”, CAVLC is selected, whereas when the “entropy_coding_mode_flag” is “1”, CABAC is selected.
With CABAC, a context index (denoted as “ctxIdx” hereinafter) is added to each code to be compressed, and the compression rate of arithmetic encoding is improved by changing and managing the appearance frequency per ctxIdx.
Here, the “context index” is an identification number added to each of classifications obtained by classifying binary data of arithmetic encoding by syntax element, adjacent macroblock information, or the like.
Encoding processing according to CABAC can be divided mainly into two processes. The first process is a process called “binarization”, in which multivalued information that is to be encoded, called a “syntax element”, is converted into binary data. The second process is a process that calculates a ctxIdx for the binary data obtained through the binarization and performs arithmetic encoding.
Processing for decoding encoded image data obtained through CABAC can, as with the aforementioned encoding, be divided into two processes. These processes are a process for outputting binary data by arithmetically decoding the encoded image data, and a process for performing multivalue conversion by converting the binary data into a syntax element.
With CABAC, the compression rate is improved by providing parameters for each picture and each slice. Specifically, there are such parameters as “pic_width_in_MBs”, “pic_height_in_MBs”, “Slice_QPy”, “cabac_init_idc”, “slice_type”, and so on. When encoding using CABAC, the initialization of random variables and so on is performed using these parameters, and encoding is executed using a set image size.
The aforementioned parameters are encoded as information contained in “seq_parameter_set_rbsp( )”, “pic_parameter_set_rbsp( ) ”, “slice_header( ) ”, and so on, and are placed before a “VCL Nal unit” in which the encoded image data is stored.
When decoding a stream encoded using H.264/AVC, “seq_parameter_set_rbsp( )”“pic_parameter_set_rbsp( )”, “slice_header( )”, and so on are decoded, and the aforementioned “entropy_coding_mode_flag” is extracted. It is then determined whether to decode using CAVLC or CABAC based on whether the value of the “entropy_coding_mode_flag” is “0” or “1”.
In the case where decoding is carried out through CABAC, the parameters used in CABAC decoding are extracted, the initialization of random variables and so on is performed using the extracted parameters, and arithmetic decoding is executed.
Meanwhile, as described earlier, the CABAC encoding and decoding processing can both be divided into two processes. These processes are the binarization and multivalue conversion of the syntax element, and the arithmetic encoding and arithmetic decoding.
By nature, the arithmetic encoding process can only encode a single bit in a single cycle, and the arithmetic decoding process can only decode a single bit in a single cycle. For this reason, it is assumed that the binarization process and the arithmetic encoding process are performed asynchronously. Likewise, it is also assumed that the multivalue conversion process and the arithmetic decoding process are performed asynchronously as well.
A method in which variable-length decoding and processes aside from variable-length decoding are performed asynchronously using a buffer exists as an image decoding method according to a conventional technique.
Specifically, in an image decoding method that decodes inputted encoded image data, each variable-length codeword within the encoded image data undergoes variable-length decoding into uniquely corresponding intermediate code, and the decoded intermediate code is temporarily stored in a buffer.
The intermediate code stored in the buffer is then read, analyzed according to the syntax of the image encoding, and the image is decoded. This method for performing the variable-length decoding and processes aside from the variable-length decoding asynchronously has been proposed (for example, see PTL 1).
The following processing flow is obtained when the method disclosed in the stated PTL 1 is applied to CABAC decoding. That is, the inputted encoded image data that has undergone arithmetic decoding is taken as intermediate code, and this intermediate code is temporarily stored in a buffer. After this, the intermediate code stored in the buffer is read, the intermediate code undergoes multivalue conversion, and the image is decoded.
FIG. 10 is a diagram illustrating an example of the data structure of a conventional stream. As shown in FIG. 10, the conventional encoded image data stream is configured in units of “NAL units”, and the parameters necessary for arithmetically decoding the encoded image data are extracted by decoding the slice header and so on
Note that “SPS” contained in the stream illustrated in FIG. 10 is the “seq_parameter_set_rbsp( )”, whereas the “PPS” is the “pic_parameter_set_rbsp( )”.
FIG. 11 is a flowchart illustrating the flow of the conventional decoding process.
In the conventional decoding process illustrated in FIG. 11, first, the SPS and PPS in the encoded image data are decoded (S200), and an “entropy_coding_mode_flag” is extracted (S202).
In the case where the “entropy_coding_mode_flag” is “1” (NO in S204), parameters are extracted from the decoded SPS and PPS (S206), and the slice header is decoded (S208).
Note, however, that in the case where the “entropy_coding_mode_flag” is “0” (S204: YES), the arithmetic decoding process (S212) is not executed (is skipped).
After this, the arithmetic decoding process is executed on the encoded image data by referring to the extracted parameters (S212). Then, in the case where there is no other encoded image data to be decoded, the process ends (S214: YES).
With the image decoding apparatus in which the stated PTL 1 has been applied, the “entropy_coding_mode_flag” is decoded in order to determine whether CAVLC or CABAC is used in the entropy encoding of the inputted encoded image data, and it can be seen that CABAC is used in the case where the value of that flag is “1”.
Next, the “seq_parameter_set_rbsp( )”, “pic_parameter_set_rbsp( )”, “slice_header( )”, and so on are decoded and parameters extracted in order to perform the CABAC arithmetic decoding. Using the extracted parameters, the initialization of random variables and so on is performed, and the arithmetic decoding process is carried out.
Here, the intermediate code is configured of the decoded image data, the “seq_parameter_set_rbsp( )”, the “pic_parameter_set_rbsp( )”, the “slice_header( )”, and so on, but in order to reduce the size of the buffer, the data aside from the decoded image data is stored in the buffer while remaining in an encoded state.
In order to perform the post-arithmetic decoding multivalue conversion process using a uniform procedure, these parameters are stored in the buffer while remaining in an encoded state.    Patent Reference 1: Japanese Patent Application Publication No. 2003-259370